package com.perfma.xtest.tool.word;

import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;

/**
 * @author: junhui.si
 * @date: 2021-08-26 10:32
 **/
public class LineDemo {

    public static void main(String[] args) {

        String sql = "#!/bin/bash\r\ndate\r\nsleep 10000\r\ndate";
        sql = sql.replaceAll("\\r\\n", "\n");
        System.out.println(sql);
    }

    public static String escape(String param) {
        if (StringUtils.isBlank(param)) {
            return param;
        }
        param = param.replaceAll("/", "//");
        param = param.replaceAll("%", "/%");
        param = param.replaceAll("_", "/_");
        return param;
    }

    public static String escape2(String source) {
        if (!Strings.isNullOrEmpty(source)) {
            source = source.replaceAll("\\\\", "\\\\\\\\");
            source = source.replaceAll("_", "\\\\_");
            source = source.replaceAll("%", "\\\\%");
        }
        return source;
    }
}
